package heven.holt.eyepetizer.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import heven.holt.eyepetizer.databinding.ItemSpecialSquareCardCollectionTypeItemBinding
import heven.holt.eyepetizer.model.ItemX

class SpecialSquareCardCollectionAdapter(
    private val itemList: List<ItemX>
) : RecyclerView.Adapter<SpecialSquareCardCollectionAdapter.SpecialSquareCardCollectionViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SpecialSquareCardCollectionViewHolder =
        SpecialSquareCardCollectionViewHolder(
            ItemSpecialSquareCardCollectionTypeItemBinding.inflate(
                LayoutInflater.from(parent.context), parent, false
            )
        )

    override fun onBindViewHolder(holder: SpecialSquareCardCollectionViewHolder, position: Int) {
        holder.binding.item = itemList[position]
        holder.binding.executePendingBindings()
    }

    override fun getItemCount(): Int = itemList.size

    class SpecialSquareCardCollectionViewHolder(val binding: ItemSpecialSquareCardCollectionTypeItemBinding) :
        RecyclerView.ViewHolder(binding.root)
}